//NvPanelItem.qml
import QtQuick 2.15
import org.ukui.nvpanel 1.0

Rectangle {
    implicitWidth: 280
    implicitHeight: 40
    radius: 6
    color: Qt.rgba(255, 255, 255, 0.5)
    border.color: "black"

    NvPanel {
        id: nvPanel
    }

    Text {
        id: text
        anchors.centerIn: parent
        text: "GPU核心：" + nvPanel.getGpuUtilization + "  GPU显存：" + nvPanel.getMemoryUtilization
        font.pointSize: 12
    }

    Component.onCompleted: {
        nvPanel.utilChanged.connect(() => {
            text.text = "GPU核心：" + nvPanel.getGpuUtilization + "  GPU显存：" + nvPanel.getMemoryUtilization
        })
    }
    Component.onDestruction: {
        nvPanel.utilChanged.disconnect()
    }

}